<template>
    <div class="Titel">
        <!-- {{list}} -->
        <template v-if="list.style=='2'&&list.type==1">
            <div>
                <van-swipe :loop="false" :width="339">
                    <van-swipe-item v-for="item in list.data" :key="item.img.url">
                        <van-image @click="jump(item.url)" :src="item.img.url" />
                    </van-swipe-item>
                </van-swipe>
            </div>
        </template>
        <template v-else>
            <div v-if="list.type == 2" class="bigBox">
                <img width="100%" :src="list.data[0].img.url" alt="">
            </div>
        </template>
    </div>
</template>

<script>
export default {
    props: {
        list: [Object, Array],
    },
    methods: {
        jump(url) {
            if (!url) {
                alert("该页面不不存在或已经删除");
            } else {
                let index = url.indexOf("t/detail?id=");
                if (index > 0) {
                    let newUrl = url.slice(index + 12);
                    console.log(newUrl);
                    this.$router.push("/productdetail" + newUrl);
                } else {
                    let index = url.indexOf("cms/activity/");
                    let newUrl = url.slice(index + 13);
                    console.log(newUrl);
                    this.$router.push("/activity" + newUrl);
                }
            }
            // console.log(newUrl);
            // console.log(-1==true);
        },
    },
};
</script>

<style lang="scss" scoped>
.Titel {
    // padding-left: 0.18rem;

    .van-swipe-item {
        padding-left: 0.18rem;
    }
}
.bigBox {
    padding: 0 0.18rem;
}

.van-image {
    ::v-deep img {
        width: 100%;
        height: 100%;
    }
}
</style>